Skip to content

fix(serve): use CREATE_NO_WINDOW for the Windows background daemon - #786

Merged
wesm merged 3 commits into
kenn-io:mainfrom
liyi0x0:fix/windows-background-no-window
Jun 20, 2026
Merged

fix(serve): use CREATE_NO_WINDOW for the Windows background daemon#786
wesm merged 3 commits into
kenn-io:mainfrom
liyi0x0:fix/windows-background-no-window

Conversation

@liyi0x0

@liyi0x0 liyi0x0 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

On Windows, agentsview serve --background makes console windows flash on
screen periodically while the server runs.

Cause

The background daemon is created with DETACHED_PROCESS in
cmd/agentsview/serve_background_windows.go, so it has no console of its own.
When it later spawns a console child -- most often git, invoked through
go.kenn.io/kit/git/cmd while resolving a session's repository/branch during
sync -- Windows must allocate a console for that child, and because the parent
has none, the child gets a brand-new visible window. It recurs because parsing
runs whenever the file watcher sees the active agent write a session file, on
the periodic (15-minute) sync, and on the unwatched-directory (2-minute) poll.
The same applies to gh when GitHub outcome metrics are enabled.

Fix

Create the daemon with CREATE_NO_WINDOW instead of DETACHED_PROCESS. The
daemon still detaches into the background, but it now owns a hidden console
that its children inherit, so git/gh run without opening visible windows.
CREATE_NEW_PROCESS_GROUP is retained so the daemon stays isolated from the
launching terminal's Ctrl-C, and terminateProcess is unchanged -- Windows
still has no POSIX-signal path, so serve stop kills the process as before.

Where to look

cmd/agentsview/serve_background_windows.go is the only file changed.

🤖 Generated with Claude Code

agentsview serve --background launched the daemon with DETACHED_PROCESS,
leaving it without a console. Every console child it later spawns --
notably git, run while resolving a session's repo during sync -- then
forces Windows to allocate a fresh, visible console window. This recurs
on each re-parse: the file watcher reacting to the active agent's writes,
the periodic sync, and the unwatched-directory poll.

Launch with CREATE_NO_WINDOW instead. The daemon still runs in the
background, but with a hidden console that children inherit, so git/gh
no longer pop windows. CREATE_NEW_PROCESS_GROUP is kept to stay isolated
from the launching terminal's Ctrl-C.
@roborev-ci

roborev-ci Bot commented Jun 20, 2026

Copy link
Copy Markdown

roborev: Combined Review (59c127f)

No issues found.


Panel: ci_default_security | Synthesis: codex | Members: codex_default (claude-code/default, done, 53s), codex_security (claude-code/security, done, 21s) | Total: 1m14s

wesm added 2 commits June 20, 2026 12:50
The Windows desktop unit job can fail before compilation when crates.io resets a Cargo registry download. Retry only the locked dependency fetch step so transient network failures get another chance, while the actual Rust update tests still run once and surface real failures normally.
The hidden-console daemon behavior depends on a small set of Windows creation flags. Add a Windows-only unit test so future edits do not silently restore DETACHED_PROCESS or drop the process-group isolation flag.
@roborev-ci

roborev-ci Bot commented Jun 20, 2026

Copy link
Copy Markdown

roborev: Combined Review (dce8443)

No issues found.


Panel: ci_default_security | Synthesis: codex | Members: codex_default (codex/default, done, 2m30s), codex_security (codex/security, done, 37s) | Total: 3m7s

@wesm
wesm merged commit ab75a8b into kenn-io:main Jun 20, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants